package org.xjo.main;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.ArrayList;

public class Main_genericCount_FTSE {



	public static   void main(String[] args) {



		StringBuffer strBufferPattern=new StringBuffer();
		BufferedReader br=null;
		String strCurrentLine=null;

		String strCurrentLineArray[]=null;

		String strCurrentUpDown=null;

		String strFiver=null;
		String strTriple=null;

		ArrayList al=null;

		int patterndepth=11;


		try{

			br=	new BufferedReader (new FileReader("C:\\historicaldata\\xjo\\ukx.csv"));
			al=new ArrayList();

			while((strCurrentLine=br.readLine())!=null){
              if(strCurrentLine!=null&&strCurrentLine.indexOf(',')>0){
            	  al.add(strCurrentLine);
            	  strCurrentLineArray=strCurrentLine.split(",");
            	//  System.out.println(strCurrentLineArray[strCurrentLineArray.length-1]);
            	  strCurrentUpDown=strCurrentLineArray[strCurrentLineArray.length-1];

            	  if(strCurrentUpDown.indexOf('-')>=0){
            		  strBufferPattern.append("D");
            	  }else{
            		  strBufferPattern.append("U");
            	  }

              }

			}
			//Eo While

			//System.out.println(strBufferPattern);

			strFiver=strBufferPattern.substring(0, patterndepth);

			System.out.println(strFiver);

			int nextIndex=0;

			//System.out.println(al.get(nextIndex-1));

			for(int i=0;i<patterndepth;i++){
				System.out.println(al.get(i));
			}



			 nextIndex=patterndepth-1;


			//System.out.println(strBufferPattern.indexOf(strFiver,nextIndex));

			while(strBufferPattern.indexOf(strFiver,nextIndex)>4){

				System.out.println("---Finding------------");

				System.out.println(strBufferPattern.indexOf(strFiver,nextIndex));
				nextIndex=strBufferPattern.indexOf(strFiver,nextIndex);

				System.out.println(al.get(nextIndex-2));
				System.out.println(" "+al.get(nextIndex-1));
				System.out.println("");
				for(int i=0;i<patterndepth;i++){
					System.out.println(al.get(nextIndex+i));
				}



				nextIndex+=1;


				System.out.println("---EOFinding------------");


			}




		}catch (Exception e) {
			e.printStackTrace();
			// TODO: handle exception
		}
		finally{
			try{
				br.close();
			}catch (Exception e) {
				e.printStackTrace();
				// TODO: handle exception
			}
		}




	}
}
